File tree 2 files changed +11
-4
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ object Checking {
110
110
* Test cases are neg/i2771.scala and neg/i2771b.scala.
111
111
*/
112
112
def preCheckKind (arg : Tree , paramBounds : TypeBounds )(implicit ctx : Context ): Tree =
113
- if (arg.tpe.hasSameKindAs(paramBounds.hi)) arg
113
+ if (arg.tpe.widen.isRef(defn. NothingClass ) || arg.tpe. hasSameKindAs(paramBounds.hi)) arg
114
114
else errorTree(arg, em " Type argument ${arg.tpe} has not the same kind as its bound $paramBounds" )
115
115
116
116
def preCheckKinds (args : List [Tree ], paramBoundss : List [TypeBounds ])(implicit ctx : Context ): List [Tree ] = {
Original file line number Diff line number Diff line change @@ -1131,16 +1131,23 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1131
1131
if (tpt1.symbol.isClass)
1132
1132
tparam match {
1133
1133
case tparam : Symbol =>
1134
- // This is needed to get the test `compileParSetSubset` to work
1135
- tparam.ensureCompleted()
1134
+ tparam.ensureCompleted() // This is needed to get the test `compileParSetSubset` to work
1136
1135
case _ =>
1137
1136
}
1138
1137
if (desugaredArg.isType) typed(desugaredArg, argPt)
1139
1138
else desugaredArg.withType(UnspecifiedErrorType )
1140
1139
}
1141
1140
args.zipWithConserve(tparams)(typedArg(_, _)).asInstanceOf [List [Tree ]]
1142
1141
}
1143
- val args2 = preCheckKinds(args1, tparams.map(_.paramInfo.bounds))
1142
+ val paramBounds = (tparams, args).zipped.map {
1143
+ case (tparam, TypeBoundsTree (EmptyTree , EmptyTree )) =>
1144
+ // if type argument is a wildcard, suppress kind checking since
1145
+ // there is no real argument.
1146
+ TypeBounds .empty
1147
+ case (tparam, _) =>
1148
+ tparam.paramInfo.bounds
1149
+ }
1150
+ val args2 = preCheckKinds(args1, paramBounds)
1144
1151
// check that arguments conform to bounds is done in phase PostTyper
1145
1152
assignType(cpy.AppliedTypeTree (tree)(tpt1, args2), tpt1, args2)
1146
1153
}
You can’t perform that action at this time.
0 commit comments