@@ -387,26 +387,26 @@ from ``OneTwoThree`` and ``int``.
387
387
Non-extending subtypes
388
388
======================
389
389
390
- Besides extending base types, classes can also declare `instanceof ` relationships with other types.
391
- Declaring a class as `instanceof Foo ` is roughly equivalent to saying `this instanceof Foo ` in the characteristic predicate.
392
- The main differences are that you can call methods on Bar via `super ` and you can get better optimisation.
390
+ Besides extending base types, classes can also declare `` instanceof ` ` relationships with other types.
391
+ Declaring a class as `` instanceof Foo `` is roughly equivalent to saying `` this instanceof Foo ` ` in the characteristic predicate.
392
+ The main differences are that you can call methods on `` Bar `` via `` super ` ` and you can get better optimisation.
393
393
394
394
.. code-block :: ql
395
395
396
396
class Foo extends int {
397
397
Foo() { this in [1 .. 10] }
398
398
399
- string foo_method () { result = "foo" }
399
+ string fooMethod () { result = "foo" }
400
400
}
401
401
402
402
class Bar instanceof Foo {
403
- string toString() { result = super.foo_method () }
403
+ string toString() { result = super.fooMethod () }
404
404
}
405
405
406
- In this example, the characteristic predicate from `Foo ` also applies to `Bar `.
407
- However, `foo_method ` is not exposed in `Bar `, so the query `select any(Bar b).foo_method() `
406
+ In this example, the characteristic predicate from `` Foo `` also applies to `` Bar ` `.
407
+ However, `` fooMethod `` is not exposed in `` Bar `` , so the query `` select any(Bar b).fooMethod() ` `
408
408
results in a compile time error. Note from the example that it is still possible to access
409
- methods from instanceof supertypes from within the specialising class with the `super ` keyword.
409
+ methods from instanceof supertypes from within the specialising class with the `` super ` ` keyword.
410
410
411
411
Crucially, the instanceof **supertypes ** are not **base types **.
412
412
This means that these supertypes do not participate in overriding, and any fields of such
@@ -430,10 +430,10 @@ The following example demonstrates this.
430
430
override string foo() { result = "bar" }
431
431
}
432
432
433
- Here, the method `Bar::foo ` does not override `Foo::foo `.
434
- Instead, it overrides only `Interface::foo `.
435
- This means that `select any(Foo f).foo() ` yields only ` foo `.
436
- Had `Bar ` been defined as `extends Foo `, then `select any(Foo b) ` would yield `bar `.
433
+ Here, the method `` Bar::foo `` does not override `` Foo::foo ` `.
434
+ Instead, it overrides only `` Interface::foo ` `.
435
+ This means that `` select any(Foo f).foo() `` yields `` foo ` `.
436
+ Had `` Bar `` been defined as `` extends Foo `` , then `` select any(Foo f).foo() `` would yield `` bar ` `.
437
437
438
438
.. _character-types :
439
439
.. _domain-types :
0 commit comments