Skip to content

Type overriding does not result in type intersection #241

Closed
@smarter

Description

@smarter

The following:

class A { type T = Int; val x: T = 1 }
class B extends A { override type T = String }

object O {
  val b: B = new B
  val s: String = b.x
}

Compiles without any error.
RefChecks.scala mentions:

        // types don't need to have their bounds in an overriding relationship
        // since we automatically form their intersection when selecting.

Should b.x have the type "Int | String" ?
CC @odersky @DarkDimius @namin .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions