E036: Dangling This In Path — 경로 끝에 붙은 this

E036: Dangling This In Path — 경로 끝에 붙은 this

이 에러는 Scala 3.0.0이 출시되기 전에 제거되었고, Scala 3 컴파일러에서 실제로 방출된 적은 없어요. 참고용으로만 읽어 주세요.

출처: Scala 3 Reference

본문

원래 했던 일 (What it did)

이 에러는 임포트 경로나 타입 선택(type selection)의 끝에서, 멤버를 선택하지 않고 this를 사용했을 때 발생했어요.

예제 (Example)

trait Outer {
  val member: Int
  type Member
  trait Inner {
    import Outer.this
  }
}

오류 메시지 (Error)

-- [E036] Syntax Error: example.scala:5:11 -------------------------------------
5 |    import Outer.this
  |           ^^^^^^^^^^
  |           Expected an additional member selection after the keyword `this`

설명 (Explanation)

임포트와 타입 선택의 경로는 키워드 this로 끝나면 안 돼요. 컴파일러는 this 뒤에 추가적인 멤버 선택이 오길 기대했어요. 올바른 사용법은 this 뒤에 멤버를 선택하는 것이었어요.

trait Outer {
  val member: Int
  type Member
  trait Inner {
    // Valid: selecting a member after this
    import Outer.this.member

    // Valid: type selection
    type T = Outer.this.Member
  }
}

더 알아보기 (Learn more)