Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1087 from hubertp/2.10.x-issue/5687
Fixes SI-5687.
- Loading branch information
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
t5687.scala:4: error: type arguments [T] do not conform to class Template's type parameter bounds [T <: AnyRef] | ||
type Repr[T]<:Template[T] | ||
^ | ||
t5687.scala:20: error: overriding type Repr in class Template with bounds[T] <: Template[T]; | ||
type Repr has incompatible type | ||
type Repr = CurveTemplate[T] | ||
^ | ||
two errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
abstract class Template[T <: AnyRef](private val t: T) { | ||
|
||
// type Repr[A<:AnyRef]<:Template[T] | ||
type Repr[T]<:Template[T] | ||
|
||
def access1(timeout: Int): Repr[T] = this.asInstanceOf[Repr[T]] | ||
def access2: Repr[T] = this.asInstanceOf[Repr[T]] | ||
val access3: Repr[T] = this.asInstanceOf[Repr[T]] | ||
def access4(v: Repr[T]): Repr[T] = this.asInstanceOf[Repr[T]] | ||
def access5(x: X): Repr[T] = this.asInstanceOf[Repr[T]] | ||
def access5(x: Y): Repr[T] = this.asInstanceOf[Repr[T]] | ||
|
||
def withReadModifiers(readModifiers:Int): Repr[T] = this.asInstanceOf[Repr[T]] | ||
} | ||
|
||
class Curve | ||
|
||
class CurveTemplate [T <: Curve](t: T) extends Template(t) { | ||
// type Repr[A<: AnyRef] = CurveTemplate[T] | ||
type Repr = CurveTemplate[T] | ||
} | ||
|
||
class Base | ||
class X extends Base | ||
class Y extends Base | ||
|
||
|
||
object Example { | ||
def test1() { | ||
new CurveTemplate(new Curve).access1(10) | ||
|
||
new CurveTemplate(new Curve).access2 | ||
|
||
new CurveTemplate(new Curve).access3 | ||
|
||
new CurveTemplate(new Curve).access4(null) | ||
|
||
new CurveTemplate(new Curve).access5(new X) | ||
|
||
() | ||
|
||
} | ||
|
||
def test2() { | ||
new CurveTemplate(new Curve).access1(10).withReadModifiers(1) | ||
|
||
new CurveTemplate(new Curve).access2.withReadModifiers(1) | ||
|
||
new CurveTemplate(new Curve).access3.withReadModifiers(1) | ||
|
||
new CurveTemplate(new Curve).access4(null).withReadModifiers(1) | ||
|
||
new CurveTemplate(new Curve).access5(new X).withReadModifiers(1) | ||
} | ||
} |