Skip to content

Commit 715811b

Browse files
committed
Don't make overriding types declared when cc is not enabled
1 parent a10c7f7 commit 715811b

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,13 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
371371
* clean retains annotations from such types. But for an overriding symbol the
372372
* retains annotations come from the explicitly declared parent types, so should
373373
* be kept.
374+
* TODO: If the overriden type is an InferredType, we should probably clean retains
375+
* from both types as well.
374376
*/
375377
private def makeOverrideTypeDeclared(symbol: Symbol, tpt: Tree)(using Context): Tree =
376378
tpt match
377379
case tpt: InferredTypeTree
378-
if symbol.allOverriddenSymbols.hasNext =>
380+
if Feature.ccEnabled && symbol.allOverriddenSymbols.hasNext =>
379381
TypeTree(tpt.tpe, inferred = false).withSpan(tpt.span).withAttachmentsFrom(tpt)
380382
case _ =>
381383
tpt

tests/pos-custom-args/captures/i24101/S1.scala renamed to tests/pos-custom-args/captures/clear-retains-for-inferred-types/S1.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ import language.experimental.captureChecking
22

33
trait MyMap[K, V]:
44
def filterNot(pred: ((K, V)) => Boolean): MyMap[K, V]^{this, pred} = ???
5+
6+
trait MySeq[+T]:
7+
def map[U](f: T => U): MySeq[U]^{this, f} = ???
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import language.experimental.{captureChecking => _}
2+
3+
// i24101
4+
5+
trait AttributeValue
6+
7+
case class CompletedSpan(
8+
name: String, // remove to make it compile
9+
attributes: MyMap[String, AttributeValue],
10+
){
11+
lazy val allAttributes: MyMap[String, AttributeValue] = attributes
12+
var allAttributes2: MyMap[String, AttributeValue] = attributes
13+
}
14+
15+
def Test =
16+
val span: CompletedSpan = ???
17+
span.copy(attributes = span.allAttributes.filterNot { _ => false })
18+
span.copy(attributes = span.allAttributes2.filterNot { _ => false })
19+
20+
// i24100
21+
22+
trait Type
23+
24+
type ColumnDef = ColumnDef_[Type]
25+
case class ColumnDef_[+T](comments: String)
26+
27+
type TableDef = TableDef_[ColumnDef]
28+
case class TableDef_[+C <: ColumnDef_[?]](cols: MySeq[C])
29+
30+
abstract class DdlGenerator:
31+
// The result type is inferred here
32+
def columnComments(t: TableDef) = t.cols.map(_ => "")
33+
34+
class CassandraDdlGenerator() extends DdlGenerator:
35+
// The result type should be inferred here as well
36+
override def columnComments(t: TableDef) = ???

tests/pos-custom-args/captures/i24101/S2.scala

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

0 commit comments

Comments
 (0)