Skip to content

Commit 7016997

Browse files
committed
Address comments
1 parent 6c6f3ce commit 7016997

File tree

5 files changed

+46
-49
lines changed

5 files changed

+46
-49
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,12 @@ object Parsers {
12791279

12801280
def expr(location: Location.Value): Tree = {
12811281
val start = in.offset
1282-
if(in.token == IMPLIED) {
1282+
// if (closureMods.contains(in.token)) {
1283+
// val imods = modifiers(closureMods)
1284+
// if (in.token == MATCH) implicitMatch(start, imods)
1285+
// else implicitClosure(start, location, imods)
1286+
// }
1287+
if(in.token == IMPLIED || in.token == IMPLICIT) {
12831288
val span = in.offset
12841289
in.nextToken()
12851290
if (in.token == MATCH)
@@ -1292,7 +1297,8 @@ object Parsers {
12921297
else if (closureMods.contains(in.token)) {
12931298
val imods = modifiers(closureMods)
12941299
implicitClosure(start, location, imods)
1295-
} else {
1300+
}
1301+
else {
12961302
val saved = placeholderParams
12971303
placeholderParams = Nil
12981304

@@ -1472,7 +1478,7 @@ object Parsers {
14721478
case _ =>
14731479
}
14741480
imods.mods match {
1475-
case Mod.Implied() :: mods => markFirstIllegal(mods)
1481+
case (Mod.Implicit() | Mod.Implied()) :: mods => markFirstIllegal(mods)
14761482
case mods => markFirstIllegal(mods)
14771483
}
14781484
val result @ Match(t, cases) =
@@ -2008,7 +2014,6 @@ object Parsers {
20082014
case ABSTRACT => Mod.Abstract()
20092015
case FINAL => Mod.Final()
20102016
case IMPLICIT => Mod.Implicit()
2011-
case IMPLIED => Mod.Implied()
20122017
case GIVEN => Mod.Given()
20132018
case ERASED => Mod.Erased()
20142019
case LAZY => Mod.Lazy()
@@ -3094,7 +3099,7 @@ object Parsers {
30943099
else if (isDefIntro(localModifierTokens))
30953100
if (closureMods.contains(in.token)) {
30963101
val start = in.offset
3097-
var imods = modifiers(closureMods + IMPLIED)
3102+
var imods = modifiers(closureMods)
30983103
if (isBindingIntro)
30993104
stats += implicitClosure(start, Location.InBlock, imods)
31003105
else if (in.token == MATCH)

library/src-bootstrapped/dotty/DottyPredef.scala

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/run/implicitMatch.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ object Test extends App {
22
import collection.immutable.TreeSet
33
import collection.immutable.HashSet
44

5-
inline def f1[T]() = implied match {
5+
inline def f1[T]() = implicit match {
66
case ord: Ordering[T] => new TreeSet[T]
77
case _ => new HashSet[T]
88
}
99

10-
inline def f2[T]() = implied match {
10+
inline def f2[T]() = implicit match {
1111
case _: Ordering[T] => new TreeSet[T]
1212
case _ => new HashSet[T]
1313
}
@@ -16,7 +16,7 @@ object Test extends App {
1616
class B
1717
implicit val b: B = new B
1818

19-
inline def g = implied match {
19+
inline def g = implicit match {
2020
case _: A => println("A")
2121
case _: B => println("B")
2222
}

tests/run/impliedMatch.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
object Test extends App {
2+
import collection.immutable.TreeSet
3+
import collection.immutable.HashSet
4+
5+
inline def f1[T]() = implied match {
6+
case ord: Ordering[T] => new TreeSet[T]
7+
case _ => new HashSet[T]
8+
}
9+
10+
inline def f2[T]() = implied match {
11+
case _: Ordering[T] => new TreeSet[T]
12+
case _ => new HashSet[T]
13+
}
14+
15+
class A
16+
class B
17+
implicit val b: B = new B
18+
19+
inline def g = implied match {
20+
case _: A => println("A")
21+
case _: B => println("B")
22+
}
23+
24+
implicitly[Ordering[String]]
25+
26+
println(f1[String]().getClass)
27+
println(f1[AnyRef]().getClass)
28+
println(f2[String]().getClass)
29+
println(f2[AnyRef]().getClass)
30+
implicitly[B]
31+
g
32+
33+
}

0 commit comments

Comments
 (0)