Skip to content

Commit 814fca6

Browse files
authored
Merge pull request #13237 from 7mind/feature/fix-#13141-kind-projector-star-failure
Fix #13141 remove spurious coercion of `*` to a _type_ identifier (was already a valid identifier)
2 parents 4f8be7d + 7bc89d6 commit 814fca6

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,8 +1609,6 @@ object Parsers {
16091609
else if isIdent(nme.?) then
16101610
val start = in.skipToken()
16111611
typeBounds().withSpan(Span(start, in.lastOffset, start))
1612-
else if isIdent(nme.*) && !ctx.settings.YkindProjector.isDefault then
1613-
typeIdent()
16141612
else
16151613
def singletonArgs(t: Tree): Tree =
16161614
if in.token == LPAREN && in.featureEnabled(Feature.dependent)

tests/neg-custom-args/kind-projector-underscores.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ longer explanation available when compiling with `-explain`
1414
| =, >:, or <: expected, but '_' found
1515

1616
longer explanation available when compiling with `-explain`
17+
-- Error: tests/neg-custom-args/kind-projector-underscores.scala:14:51 -------------------------------------------------
18+
14 |class BacktickUnderscoreIsNotFine extends Foo[List[`_`]] // error wildcard invalid as backquoted identifier
19+
| ^
20+
| wildcard invalid as backquoted identifier
1721
-- Error: tests/neg-custom-args/kind-projector-underscores.scala:5:23 --------------------------------------------------
1822
5 |class Bar1 extends Foo[Either[_, _]] // error
1923
| ^^^^^^^^^^^^

tests/neg-custom-args/kind-projector-underscores.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ object Test {
1010
type -_ = Int // error -_ not allowed as a type def name without backticks
1111
type +_ = Int // error +_ not allowed as a type def name without backticks
1212
}
13+
14+
class BacktickUnderscoreIsNotFine extends Foo[List[`_`]] // error wildcard invalid as backquoted identifier

tests/pos-special/kind-projector.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,20 @@ class VarianceAnnotationIsActuallyIgnored6 extends FooPlus[λ[`-x` => Either[Int
4141
class VarianceAnnotationIsActuallyIgnored7 extends QuxPlus[λ[(`-x`, `-y`) => Either[y, x]]]
4242
class VarianceAnnotationIsActuallyIgnored8 extends FooPlus[BazPlus[Int => -*, -*, Int]]
4343
class VarianceAnnotationIsActuallyIgnored9 extends Foo[λ[`-x` => BazPlus[x => -*, Int, x]]]
44+
45+
class BackticksAreFine1 extends FooPlus[Either[Int, `-*`]]
46+
class BackticksAreFine2 extends FooPlus[Either[`-*`, Int]]
47+
class BackticksAreFine3 extends FooMinus[`+*` => Int]
48+
class BackticksAreFine4 extends FooPlus[Int => `-*`]
49+
class BackticksAreFine5 extends FooPlus[(Int, `-*`, Int)]
50+
class BackticksAreFine6 extends FooPlus[BazPlus[Int => `-*`, `-*`, Int]]
51+
class BackticksAreFine7 extends Foo[λ[`-x` => BazPlus[x => `-*`, Int, x]]]
52+
class BackticksAreFine8 extends Foo[λ[`x` => BazPlus[x => `*`, Int, x]]]
53+
54+
// https://github.com/lampepfl/dotty/issues/13141
55+
// i13141
56+
object A {
57+
class X { type Blah = Int }
58+
val * = new X
59+
val a: *.Blah = 2
60+
}

0 commit comments

Comments
 (0)