Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-10199

Illegal cyclic reference involving type member of a constructor argument overriding a val

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.12.1
    • Fix Version/s: None
    • Component/s: Type Checker
    • Labels:
      None

      Description

      There are several bugs reported already regarding "illegal cyclic reference", the closest one probably being SI-7642. What might be special about this one is that it involves a type member of a constructor argument (foo.A below). What seems to confuse the type checker is the fact that the constructor argument also overrides a val.

      trait Foo {
        type A
      }
       
      trait Bar {
        type B
        val foo: Foo { type A = B }
      }
       
      class Bar1(val foo: Foo) extends Bar {
        type B = foo.A // error: illegal cyclic reference involving type B
      }
       
      // workaround
      class Bar2(val foo0: Foo) extends Bar {
        type B = foo0.A // OK
        val foo = foo0  // OK
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tomas.mikula@gmail.com Tomas Mikula
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: