File tree 4 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc
4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -641,9 +641,7 @@ object Types {
641
641
val rinfo = tp.refinedInfo
642
642
if (name.isTypeName && ! pinfo.isInstanceOf [ClassInfo ]) { // simplified case that runs more efficiently
643
643
val jointInfo =
644
- if (rinfo.isTypeAlias) rinfo
645
- else if (pinfo.isTypeAlias) pinfo
646
- else if (ctx.base.pendingMemberSearches.contains(name)) pinfo safe_& rinfo
644
+ if (ctx.base.pendingMemberSearches.contains(name)) pinfo safe_& rinfo
647
645
else pinfo recoverable_& rinfo
648
646
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
649
647
} else {
Original file line number Diff line number Diff line change @@ -268,6 +268,9 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
268
268
case tree : New if isCheckable(tree) =>
269
269
Checking .checkInstantiable(tree.tpe, tree.pos)
270
270
super .transform(tree)
271
+ case tree : Closure if ! tree.tpt.isEmpty =>
272
+ Checking .checkRealizable(tree.tpt.tpe, tree.pos, " SAM type" )
273
+ super .transform(tree)
271
274
case tree @ Annotated (annotated, annot) =>
272
275
cpy.Annotated (tree)(transform(annotated), transformAnnot(annot))
273
276
case tree : AppliedTypeTree =>
Original file line number Diff line number Diff line change @@ -136,10 +136,10 @@ object Checking {
136
136
}
137
137
138
138
/** Check that type `tp` is realizable. */
139
- def checkRealizable (tp : Type , pos : Position )(implicit ctx : Context ): Unit = {
139
+ def checkRealizable (tp : Type , pos : Position , what : String = " path " )(implicit ctx : Context ): Unit = {
140
140
val rstatus = realizability(tp)
141
141
if (rstatus ne Realizable )
142
- ctx.errorOrMigrationWarning(em " $tp is not a legal path \n since it ${rstatus.msg}" , pos)
142
+ ctx.errorOrMigrationWarning(em " $tp is not a legal $what \n since it ${rstatus.msg}" , pos)
143
143
}
144
144
145
145
/** A type map which checks that the only cycles in a type are F-bounds
Original file line number Diff line number Diff line change
1
+ trait SAM {
2
+ type T >: Int
3
+ def apply (x : Int ): Int
4
+ def t : T = 1
5
+ }
6
+
7
+ object O {
8
+ def main (a: Array [String ])= {
9
+ val fn : SAM {type T = String } = (i: Int ) => i // error: SAM{T = String} is not a legal SAM type
10
+ def cce : String = fn.t
11
+ println(cce)
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments