Skip to content

Commit d5bf538

Browse files
committed
Support definition site tracked with type bounds
1 parent f63a839 commit d5bf538

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ class Namer { typer: Typer =>
20732073
val sym = symbolOfTree(param)
20742074
sym.maybeOwner.maybeOwner.infoOrCompleter match
20752075
case info: ClassInfo
2076-
if !sym.is(Tracked) && (sym.info.typeSymbol.is(Tracked) || isContextBoundWitnessWithAbstractMembers(sym, param, sym.maybeOwner.maybeOwner)) =>
2076+
if !sym.is(Tracked) && (sym.info.widen.typeSymbol.is(Tracked) || isContextBoundWitnessWithAbstractMembers(sym, param, sym.maybeOwner.maybeOwner)) =>
20772077
typr.println(i"set tracked $param, $sym: ${sym.info} containing ${sym.info.memberNames(abstractTypeNameFilter).toList}")
20782078
setParamTrackedWithAccessors(sym, info)
20792079
case _ =>

tests/neg/abstract-tracked.check

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:4:14 ----------------------------------------------------------
2-
4 |tracked trait F // error
3-
|^^^^^^^^^^^^^^^
4-
|Modifier tracked is not allowed for this definition
51
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:9:15 ----------------------------------------------------------
62
9 |tracked object O // error
73
|^^^^^^^^^^^^^^^^
84
|Modifier tracked is not allowed for this definition
9-
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:11:14 ---------------------------------------------------------
10-
11 |tracked class C // error
11-
|^^^^^^^^^^^^^^^
12-
|Modifier tracked is not allowed for this definition
135
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:7:14 ----------------------------------------------------------
146
7 | tracked def f: F // error
157
| ^^^^^^^^^^^^^^^^

tests/neg/abstract-tracked.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import scala.language.experimental.modularity
22
import scala.language.future
33

4-
tracked trait F // error
4+
tracked trait F
55

66
trait G:
77
tracked def f: F // error
88

99
tracked object O // error
1010

11-
tracked class C // error
11+
tracked class C
1212

1313
def f =
1414
tracked val x = 1 // error

tests/neg/tracked.check

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
11 | tracked object Foo // error
2323
| ^^^^^^^^^^^^^^^^^^
2424
| Modifier tracked is not allowed for this definition
25-
-- [E156] Syntax Error: tests/neg/tracked.scala:14:16 ------------------------------------------------------------------
26-
14 | tracked class D // error
27-
| ^^^^^^^^^^^^^^^
28-
| Modifier tracked is not allowed for this definition
2925
-- [E156] Syntax Error: tests/neg/tracked.scala:17:15 ------------------------------------------------------------------
3026
17 | tracked type T = Int // error
3127
| ^^^^^^^^^^^^^^^^^^^^

tests/neg/tracked.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object B:
1111
tracked object Foo // error
1212

1313
object C:
14-
tracked class D // error
14+
tracked class D
1515

1616
object D:
1717
tracked type T = Int // error

tests/pos/definition-site-tracked.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ given ShowPerson: Show[Person] with
1111
class Person(val name: String)(val showW: Show[Person]):
1212
def show = showW.show(this)
1313

14+
given ShowString: Show[String] with
15+
type Out = Double
16+
def show(self: String): Double = self.length.toDouble
17+
18+
class Person1[S <: Show[String]](val name: String)(val showW: S):
19+
def show = showW.show(name)
20+
1421
def Test =
1522
val kasia = Person("Kasia")(ShowPerson)
1623
val _: Int = kasia.show
24+
val kasia1 = Person1("Kasia")(ShowString)
25+
val _: Double = kasia1.show

0 commit comments

Comments
 (0)