File: complete_overridden_decls.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (89 lines) | stat: -rw-r--r-- 4,623 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// RUN: sed -n -e '1,/NO_ERRORS_UP_TO_HERE$/ p' %s > %t_no_errors.swift
// RUN: %target-swift-frontend -typecheck -verify %t_no_errors.swift

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVER_BASE_1 > %t.over.txt
// RUN: %FileCheck %s -check-prefix=OVER_BASE_1 < %t.over.txt

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVER_DERIVED_1 > %t.over.txt
// RUN: %FileCheck %s -check-prefix=OVER_DERIVED_1 < %t.over.txt

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVER_MORE_DERIVED_1 > %t.over.txt
// RUN: %FileCheck %s -check-prefix=OVER_MORE_DERIVED_1 < %t.over.txt

//===---
//===--- Check that we don't show overridden decls (only show the overriding decl).
//===---

class FooBase {}
class FooDerived : FooBase {}
class FooMoreDerived : FooDerived {}

class TestABase {
  var baseInstanceVar: FooBase { return FooBase() }

  var baseOverInstanceVar: FooBase { return FooBase() }

  func baseOverFunc() {}
  func baseOverContravariant(_ a: FooMoreDerived) {}
  func baseOverCovariant() -> FooBase {}
}
class TestADerived : TestABase {
  var derivedInstanceVar: FooBase { return FooBase() }

  override var baseOverInstanceVar: FooDerived { return FooDerived() }
  var derivedOverInstanceVar: FooBase { return FooBase() }

  override func baseOverFunc() {}
  override func baseOverContravariant(_ a: FooDerived) {}
  override func baseOverCovariant() -> FooDerived {}
}
class TestAMoreDerived : TestADerived {
  var moreDerivedInstanceVar: FooBase { return FooBase() }

  override var baseOverInstanceVar: FooMoreDerived { return FooMoreDerived() }
  override var derivedOverInstanceVar: FooDerived { return FooDerived() }

  override func baseOverFunc() {}
  override func baseOverContravariant(_ a: FooBase) {}
  override func baseOverCovariant() -> FooMoreDerived {}
}

// NO_ERRORS_UP_TO_HERE

func test1(_ b: TestABase) {
  b.#^OVER_BASE_1^#
}
// OVER_BASE_1: Begin completions, 6 items
// OVER_BASE_1-DAG: Keyword[self]/CurrNominal: self[#TestABase#]; name=self
// OVER_BASE_1-DAG: Decl[InstanceVar]/CurrNominal:    baseInstanceVar[#FooBase#]{{; name=.+$}}
// OVER_BASE_1-DAG: Decl[InstanceVar]/CurrNominal:    baseOverInstanceVar[#FooBase#]{{; name=.+$}}
// OVER_BASE_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverFunc()[#Void#]{{; name=.+$}}
// OVER_BASE_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverContravariant({#(a): FooMoreDerived#})[#Void#]{{; name=.+$}}
// OVER_BASE_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverCovariant()[#FooBase#]{{; name=.+$}}

func test2(_ d: TestADerived) {
  d.#^OVER_DERIVED_1^#
}
// OVER_DERIVED_1: Begin completions, 8 items
// OVER_DERIVED_1-DAG: Keyword[self]/CurrNominal: self[#TestADerived#]; name=self
// OVER_DERIVED_1-DAG: Decl[InstanceVar]/CurrNominal:    derivedInstanceVar[#FooBase#]{{; name=.+$}}
// OVER_DERIVED_1-DAG: Decl[InstanceVar]/CurrNominal:    baseOverInstanceVar[#FooDerived#]{{; name=.+$}}
// OVER_DERIVED_1-DAG: Decl[InstanceVar]/CurrNominal:    derivedOverInstanceVar[#FooBase#]{{; name=.+$}}
// OVER_DERIVED_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverFunc()[#Void#]{{; name=.+$}}
// OVER_DERIVED_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverContravariant({#(a): FooDerived#})[#Void#]{{; name=.+$}}
// OVER_DERIVED_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverCovariant()[#FooDerived#]{{; name=.+$}}
// OVER_DERIVED_1-DAG: Decl[InstanceVar]/Super:          baseInstanceVar[#FooBase#]{{; name=.+$}}

func test3(_ md: TestAMoreDerived) {
  md.#^OVER_MORE_DERIVED_1^#
}
// OVER_MORE_DERIVED_1: Begin completions, 9 items
// OVER_MORE_DERIVED_1-DAG: Keyword[self]/CurrNominal: self[#TestAMoreDerived#]; name=self
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceVar]/CurrNominal:    moreDerivedInstanceVar[#FooBase#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceVar]/CurrNominal:    baseOverInstanceVar[#FooMoreDerived#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceVar]/CurrNominal:    derivedOverInstanceVar[#FooDerived#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverFunc()[#Void#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverContravariant({#(a): FooBase#})[#Void#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceMethod]/CurrNominal: baseOverCovariant()[#FooMoreDerived#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceVar]/Super:          derivedInstanceVar[#FooBase#]{{; name=.+$}}
// OVER_MORE_DERIVED_1-DAG: Decl[InstanceVar]/Super:          baseInstanceVar[#FooBase#]{{; name=.+$}}