File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -641,9 +641,7 @@ object Types {
641641 val rinfo = tp.refinedInfo
642642 if (name.isTypeName && ! pinfo.isInstanceOf [ClassInfo ]) { // simplified case that runs more efficiently
643643 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
647645 else pinfo recoverable_& rinfo
648646 pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
649647 } else {
Original file line number Diff line number Diff line change @@ -268,6 +268,9 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
268268 case tree : New if isCheckable(tree) =>
269269 Checking .checkInstantiable(tree.tpe, tree.pos)
270270 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)
271274 case tree @ Annotated (annotated, annot) =>
272275 cpy.Annotated (tree)(transform(annotated), transformAnnot(annot))
273276 case tree : AppliedTypeTree =>
Original file line number Diff line number Diff line change @@ -136,10 +136,10 @@ object Checking {
136136 }
137137
138138 /** 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 = {
140140 val rstatus = realizability(tp)
141141 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)
143143 }
144144
145145 /** 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