Skip to content

Commit 1d04427

Browse files
committed
Fix #4382: Fix checking that hk types cannot take wildcard arguments
Four existing test cases had to be reclassified to require -language:Scala2.
1 parent 0d532d5 commit 1d04427

File tree

8 files changed

+19
-11
lines changed

8 files changed

+19
-11
lines changed

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Symbols._
99
import Contexts._
1010
import Decorators.PreNamedString
1111
import util.NameTransformer
12-
import scala.collection.breakOut
1312

1413
object StdNames {
1514

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import dotty.tools.dotc.transform.Erasure
2929
import printing.Printer
3030
import Hashable._
3131
import Uniques._
32-
import collection.{mutable, Seq, breakOut}
32+
import collection.{mutable, Seq}
3333
import config.Config
3434
import annotation.tailrec
3535
import Flags.FlagSet

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,11 @@ object Checking {
8686
if (boundsCheck) checkBounds(orderedArgs, bounds, instantiate)
8787

8888
def checkWildcardApply(tp: Type, pos: Position): Unit = tp match {
89-
case tp @ AppliedType(tycon, args) if args.exists(_.isInstanceOf[TypeBounds]) =>
90-
tycon match {
91-
case tycon: TypeLambda =>
92-
ctx.errorOrMigrationWarning(
93-
ex"unreducible application of higher-kinded type $tycon to wildcard arguments",
94-
pos)
95-
case _ =>
96-
checkWildcardApply(tp.superType, pos)
97-
}
89+
case tp @ AppliedType(tycon, args) =>
90+
if (tycon.isLambdaSub && args.exists(_.isInstanceOf[TypeBounds]))
91+
ctx.errorOrMigrationWarning(
92+
ex"unreducible application of higher-kinded type $tycon to wildcard arguments",
93+
pos)
9894
case _ =>
9995
}
10096
def checkValidIfApply(implicit ctx: Context): Unit =

tests/neg/i4382.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
object App {
2+
type Id[A] >: A <: A
3+
def v1: Id[_] = ??? // error
4+
5+
type HkL[A] >: A
6+
def v2: HkL[_] = ??? // error
7+
8+
type HkU[A] <: A
9+
def v3: HkU[_] = ??? // error
10+
11+
type HkAbs[A]
12+
def v4: HkAbs[_] = ??? // error
13+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)