File tree 4 files changed +17
-6
lines changed
compiler/src/dotty/tools/dotc 4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
195
195
case MatchTypeScrutineeCannotBeHigherKindedID // errorNumber: 179
196
196
case AmbiguousExtensionMethodID // errorNumber 180
197
197
case UnqualifiedCallToAnyRefMethodID // errorNumber: 181
198
+ case ClosureCannotHaveInternalParameterDependenciesID // errorNumber: 182
198
199
199
200
def errorNumber = ordinal - 1
200
201
Original file line number Diff line number Diff line change @@ -2906,3 +2906,10 @@ class MatchTypeScrutineeCannotBeHigherKinded(tp: Type)(using Context)
2906
2906
extends TypeMsg (MatchTypeScrutineeCannotBeHigherKindedID ) :
2907
2907
def msg (using Context ) = i " the scrutinee of a match type cannot be higher-kinded "
2908
2908
def explain (using Context ) = " "
2909
+
2910
+ class ClosureCannotHaveInternalParameterDependencies (mt : Type )(using Context )
2911
+ extends TypeMsg (ClosureCannotHaveInternalParameterDependenciesID ):
2912
+ def msg (using Context ) =
2913
+ i """ cannot turn method type $mt into closure
2914
+ |because it has internal parameter dependencies """
2915
+ def explain (using Context ) = " "
Original file line number Diff line number Diff line change @@ -1686,19 +1686,20 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1686
1686
TypeTree (targetTpe)
1687
1687
case _ =>
1688
1688
if (mt.isParamDependent)
1689
- errorTree(tree,
1690
- em """ cannot turn method type $mt into closure
1691
- |because it has internal parameter dependencies """ )
1689
+ errorTree(tree, ClosureCannotHaveInternalParameterDependencies (mt))
1692
1690
else if hasCaptureConversionArg(mt.resType) then
1693
1691
errorTree(tree,
1694
1692
em """ cannot turn method type $mt into closure
1695
1693
|because it has capture conversion skolem types """ )
1696
1694
else
1697
1695
EmptyTree
1698
1696
}
1699
- case _ : PolyType =>
1700
- // Polymorphic SAMs are not currently supported (#6904).
1701
- EmptyTree
1697
+ case poly @ PolyType (_, mt : MethodType ) =>
1698
+ if (mt.isParamDependent)
1699
+ errorTree(tree, ClosureCannotHaveInternalParameterDependencies (poly))
1700
+ else
1701
+ // Polymorphic SAMs are not currently supported (#6904).
1702
+ EmptyTree
1702
1703
case tp =>
1703
1704
if ! tp.isErroneous then
1704
1705
throw new java.lang.Error (i " internal error: closing over non-method $tp, pos = ${tree.span}" )
Original file line number Diff line number Diff line change @@ -2,4 +2,6 @@ object Test {
2
2
val pv0 : [T ] => List [T ] = ??? // error
3
3
val pv1 : Any = [T ] => Nil // error
4
4
val pv2 : [T ] => List [T ] = [T ] => Nil // error // error
5
+
6
+ val intraDep = [T ] => (x : T , y : List [x.type ]) => List (y) // error
5
7
}
You can’t perform that action at this time.
0 commit comments